﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Utility
{
    public class RandomUtil
    {
        /// <summary>
        /// 使用Guid产生的种子生成真随机数
        /// </summary>
        public static string GetRandomNumber(int len)
        {
            char[] arrChar = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
            StringBuilder code = new StringBuilder();
            Random random = new Random(Guid.NewGuid().GetHashCode());
            for (int i = 0; i < len; i++)
            {
                code.Append(arrChar[random.Next(0, arrChar.Length)].ToString());
            }
            return code.ToString();
        }
    }
}
